<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1{
            position: absolute;
            width: 300px;
            height: 300px;
            background-color: antiquewhite;
        }
        
        #box2{
            position: relative;
            margin-left: 150px;
            margin-top: 0px;
            width: 150px;
            height: 150px;
            background-color: aqua;
        }
        #box3{
            /* position: absolute; */
            background-color: burlywood;
            width: 300px;
            height: 300px;
        }
        #sp{
            margin-left: 150px;
            background-color: aqua;
        }
    </style>
    <script>
        window.onload = function(){
            var bt1 = document.getElementById('bt1');
            var box1 = bt1.parentElement;
            bt1.onclick = function(){
                box1.style.backgroundColor = 'lightyellow'
            }
            var bt2 = document.getElementById('bt2');
            var box2 = bt2.parentElement;
            bt2.onclick = function(){
                box2.style.backgroundColor = "lightgreen"
            }

            // var span = document.getElementById("sp");
            // span.onclick = function(){
            //     alert('span标签');
                
            // }
            // var box = document.getElementById('box3');
            // box3.onclick = function(event){
            //     alert('box3');
            //     event.stopPropagation();
            // }
            var body = document.body;
            body.onclick = function(){
                alert('body');
                
            }
        }
    </script>
</head>
<body>
    <div id="box3">
        box3
        <span id="sp">span标签</span>
    </div>
    <div id="box1">
        <button id="bt1">按钮一</button>
        <div id="box2">
            <button id="bt2">按钮2</button>
        </div>
    </div>
</body>
</html>